package toolib.geom;

/**
 * Triangle by three points in 2d space.
 * 
 * @author Steffen Fiedler
 */
public class Triangle2D {
	
	public V2f a;
	public V2f b;
	public V2f c;
	
	public Triangle2D () {
		a = new V2f ();
		b = new V2f ();
		c = new V2f ();
	}
	
	public Triangle2D (V2f theA, V2f theB, V2f theC) {
		a = theA;
		b = theB;
		c = theC;
	}
	
	public Triangle2D (float theAX, float theAY, float theBX, float theBY, float theCX, float theCY) {
		a = new V2f (theAX, theAY);
		b = new V2f (theBX, theBY);
		c = new V2f (theCX, theCY);
	}
	
	public V2f center () {
		return new V2f ((a.x + b.x + c.x) / 3, (a.y + b.y + c.y) / 3);
	}
	
	public void set (V2f theA, V2f theB, V2f theC) {
		a = theA;
		b = theB;
		c = theC;
	}
	
	public Line2D segmentAB () {
		return new Line2D (a, b);
	}
	
	public Line2D segmentAC () {
		return new Line2D (a, c);
	}
	
	public Line2D segmentBC () {
		return new Line2D (b, c);
	}
}